package cn.edu.scut.fsearch.servlet;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import cn.edu.scut.fsearch.data.SourceStatistic;

public class SourceStatisticServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		resp.setCharacterEncoding("UTF-8");
		ServletContext s1=this.getServletContext(); 
         String temp=s1.getRealPath("/"); 
         temp = temp+"/WEB-INF/classes/region.xml";
		SourceStatistic sourceStatistic = new SourceStatistic(temp);
		Map<String, Object> map = sourceStatistic.getJsonObjectMap();
		resp.getWriter().print(JSONObject.fromObject(map).toString());
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(req, resp);
	}

}
